package com.caipiao.lottery.lty.message;

import com.caipiao.lottery.config.Config;

public class LtyMsgBodyFactory
{
	//Bean路径
	static final String path = LtyMsgBodyFactory.class.getPackage().getName() + ".bean.LtyMsgBody";
	
	public static MessageRequest GetLtyReqBody(String cmd)
	{
		try
		{
			String beanName = Config.Interface.GetPropValue("Cmd.ReqMsgClass", cmd);
			
			if (null == beanName || beanName.isEmpty())
			{
				beanName = path + cmd + "$Req";
			}
			
			Class<?> msgBody = Class.forName(beanName);

			return (MessageRequest) msgBody.newInstance();
		}
		catch (Exception e)
		{
			System.out.print(e);
		}
		return null;
	};

	public static MessageResponse GetLtyRespBody(String cmd)
	{
		try
		{
			String beanName = Config.Interface.GetPropValue("Cmd.RespMsgClass", cmd);
			
			if (null == beanName || beanName.isEmpty())
			{
				beanName = path + cmd + "$Resp";
			}
			
			Class<?> msgBody = Class.forName(beanName);

			return (MessageResponse) msgBody.newInstance();
		} 
		catch (Exception e)
		{
			System.out.print(e);
		}
		return null;
	};
}